package Leetcode;

import tree.TreeNode;

public class invertTree {
    public TreeNode invertTree(TreeNode root) {
        if (root == null) {
            return null;
        }
        invertTree(root.right);
        invertTree(root.left);
        swap(root);
        return root;
    }
    public void swap(TreeNode node) {
        TreeNode temp;
        temp = node.left;
        node.left = node.right;
        node.right = temp;
    }
}
